home *** CD-ROM | disk | FTP | other *** search
Wrap
RRRRWWWWTTTTVVVVaaaallllMMMMaaaappppIIIItttteeeerrrraaaattttoooorrrr((((3333CCCC++++++++)))) RRRRWWWWTTTTVVVVaaaallllMMMMaaaappppIIIItttteeeerrrraaaattttoooorrrr((((3333CCCC++++++++)))) NNNNaaaammmmeeee RWTValMapIterator<K,T,C> - Rogue Wave library class SSSSyyyynnnnooooppppssssiiiissss #include<rw/tvmap.h> RWTValMap<K,T,C> vm; RWTValMapIterator<K,T,C> itr(vm); SSSSttttaaaannnnddddaaaarrrrdddd CCCC++++++++ LLLLiiiibbbbrrrraaaarrrryyyy DDDDeeeeppppeeeennnnddddeeeennnntttt!!!! RRRRWWWWTTTTVVVVaaaallllMMMMaaaappppIIIItttteeeerrrraaaattttoooorrrr requires the Standard C++ Library. DDDDeeeessssccccrrrriiiippppttttiiiioooonnnn RRRRWWWWTTTTVVVVaaaallllMMMMaaaappppIIIItttteeeerrrraaaattttoooorrrr is supplied with TTTToooooooollllssss....hhhh++++++++ 7 to provide an iterator interface to RRRRWWWWTTTTVVVVaaaallllMMMMaaaappppIIIItttteeeerrrraaaattttoooorrrr that is backward compatable with the container iterators provided in TTTToooooooollllssss....hhhh++++++++ 6.x. The order of iteration over an RRRRWWWWTTTTVVVVaaaallllMMMMaaaapppp is dependent on the comparator object supplied as applied to the key values of the stored associations. The current item referenced by this iterator is undefined after construction or after a call to rrrreeeesssseeeetttt(((()))). The iterator becomes valid after being advanced with either a preincrement or ooooppppeeeerrrraaaattttoooorrrr(((()))). For both ooooppppeeeerrrraaaattttoooorrrr++++++++ and ooooppppeeeerrrraaaattttoooorrrr(((()))), iterating past the last element will return a value equivalent to boolean ffffaaaallllsssseeee. Continued increments will return a value equivalent to ffffaaaallllsssseeee until rrrreeeesssseeeetttt(((()))) is called. PPPPeeeerrrrssssiiiisssstttteeeennnncccceeee None xxxxaaaammmmpppplllleeeessss #include<rw/tvmap.h> #include<iostream.h> #include<rw/cstring.h> int main(){ RWTValMap<RWCString,int,greater<RWCString> > age; RWTValMapIterator<RWCString,int,greater<RWCString> > itr(age); age.insert("John", 30); age.insert("Steve",17); age.insert("Mark",24); //Insertion is rejected, no duplicates allowed age.insert("Steve",24); for(;itr();) cout << itr.key() << "'s age is " << itr.value() << endl; PPPPaaaaggggeeee 1111 RRRRWWWWTTTTVVVVaaaallllMMMMaaaappppIIIItttteeeerrrraaaattttoooorrrr((((3333CCCC++++++++)))) RRRRWWWWTTTTVVVVaaaallllMMMMaaaappppIIIItttteeeerrrraaaattttoooorrrr((((3333CCCC++++++++)))) return 0; } Program Output Steve's age is 17 Mark's age is 24 PPPPuuuubbbblllliiiicccc CCCCoooonnnnssssttttrrrruuuuccccttttoooorrrrssss John's age is 30 RRRRWWWWTTTTVVVVaaaallllMMMMaaaappppIIIItttteeeerrrraaaattttoooorrrr<<<<KKKK,,,,TTTT,,,,CCCC>>>> (RWTValMap<K,T,C>&h); Creates an iterator for the map hhhh. The iterator begins in an undefined state and must be advanced before the first association will be accessible. PPPPuuuubbbblllliiiicccc MMMMeeeemmmmbbbbeeeerrrr OOOOppppeeeerrrraaaattttoooorrrrssss RWBoolean ooooppppeeeerrrraaaattttoooorrrr(((())))(); Advances sssseeeellllffff to the next element. If the iterator has advanced past the last element in the collection, ffffaaaallllsssseeee will be returned. Otherwise, ttttrrrruuuueeee will be returned. RWBoolean ooooppppeeeerrrraaaattttoooorrrr++++++++(); Advances sssseeeellllffff to the next element. If the iterator has been reset or just created sssseeeellllffff will now reference the first element. If, before iteration, sssseeeellllffff pointed to the last association in the map, sssseeeellllffff will now reference an undefined value and ffffaaaallllsssseeee will be returned. Otherwise, ttttrrrruuuueeee is returned. Note: no postincrement operator is provided. PPPPuuuubbbblllliiiicccc MMMMeeeemmmmbbbbeeeerrrr FFFFuuuunnnnccccttttiiiioooonnnnssss RWTValMap<K,T,C>* ccccoooonnnnttttaaaaiiiinnnneeeerrrr(((()))) const; Returns a pointer to the collection being iterated over. PPPPaaaaggggeeee 2222 RRRRWWWWTTTTVVVVaaaallllMMMMaaaappppIIIItttteeeerrrraaaattttoooorrrr((((3333CCCC++++++++)))) RRRRWWWWTTTTVVVVaaaallllMMMMaaaappppIIIItttteeeerrrraaaattttoooorrrr((((3333CCCC++++++++)))) K kkkkeeeeyyyy() const; Returns the key portion of the association currently referenced by sssseeeellllffff. void rrrreeeesssseeeetttt(); void rrrreeeesssseeeetttt(RWTValMap<K,T,C>& h); Resets the iterator so that after being advanced it will reference the first element of the collection. Using rrrreeeesssseeeetttt(((()))) with no argument will reset the iterator on the current container. Supplying a RRRRWWWWTTTTVVVVaaaallllMMMMaaaapppp with rrrreeeesssseeeetttt(((()))) will reset the iterator on that container. T vvvvaaaalllluuuueeee(); Returns the value portion of the association referenced by sssseeeellllffff. PPPPaaaaggggeeee 3333